using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class MouseClick : MonoBehaviour
{
    [SerializeField] private Camera displayCam;
    [SerializeField] private Sprite circle;

    private SpriteRenderer sr;

    private BoxCollider2D b2d;
    // Start is called before the first frame update
    void Start()
    {
        sr = this.GetComponent<SpriteRenderer>();
        b2d = this.GetComponent<BoxCollider2D>();
    }

    // Update is called once per frame
    void Update()
    {
        //if (Input.GetMouseButtonDown(0))
        //{
            Vector2 MouseAxis = Input.mousePosition;
            Vector2 mouseWorldpos = displayCam.ScreenToWorldPoint(MouseAxis);
            this.transform.position = mouseWorldpos;
        //}

        if (Input.GetMouseButton(0))
        {
            sr.sprite = circle;
            b2d.enabled = true;
        }
        else if(!Input.GetMouseButton(0))
        {
            sr.sprite = null;
            b2d.enabled = false;
        }
    }
}
